package com.example.oa;

import jdk.nashorn.internal.ir.RuntimeNode;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

    @WebFilter("/*") // wildcard 外卡
public class EncodingFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        //设置参数编码字符集
        servletRequest.setCharacterEncoding("UTF-8");
        servletResponse.setCharacterEncoding("UTF-8");
        //chain 链 filterChain 过滤器链 作用是 传给下一个过滤器链（没有下一个过滤器就处理请求）就行过滤
        filterChain.doFilter(servletRequest,servletResponse);


//        HttpServletRequest httpRequest = (HttpServletRequest) servletRequest ;


    }
}


